(Fdefvar): Only record (defvar <var>) in the load-history
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 14 May 2001 20:52:07 +0000 (20:52 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 14 May 2001 20:52:07 +0000 (20:52 +0000)
in <var> has no default value yet.

src/eval.c

index f7dd17eb5eae9cfcd40377c5c87f43e346587ff7..42dcc814bb6732ead5d6136429b4e603274f7e51 100644 (file)
@@ -686,21 +686,28 @@ If INITVALUE is missing, SYMBOL's value is not set.")
   if (!NILP (Fcdr (Fcdr (tail))))
     error ("too many arguments");
 
+  tem = Fdefault_boundp (sym);
   if (!NILP (tail))
     {
-      tem = Fdefault_boundp (sym);
       if (NILP (tem))
-       Fset_default (sym, Feval (Fcar (Fcdr (args))));
-    }
-  tail = Fcdr (Fcdr (args));
-  if (!NILP (Fcar (tail)))
-    {
-      tem = Fcar (tail);
-      if (!NILP (Vpurify_flag))
-       tem = Fpurecopy (tem);
-      Fput (sym, Qvariable_documentation, tem);
+       Fset_default (sym, Feval (Fcar (tail)));
+      tail = Fcdr (tail);
+      if (!NILP (Fcar (tail)))
+       {
+         tem = Fcar (tail);
+         if (!NILP (Vpurify_flag))
+           tem = Fpurecopy (tem);
+         Fput (sym, Qvariable_documentation, tem);
+       }
+      LOADHIST_ATTACH (sym);
     }
-  LOADHIST_ATTACH (sym);
+  else
+    /* A (defvar <var>) should not take precedence in the load-history over
+       an earlier (defvar <var> <val>), so only add to history if the default
+       value is still unbound.  */
+    if (NILP (tem))
+      LOADHIST_ATTACH (sym);
+    
   return sym;
 }